package com.suanfa.dp;

/**
 * 打家劫舍， 抢相邻的客户会被发现先报警
 */
public class Thief1 {

    public static void main(String[] args) {
        int[] arr = {2,7,9,3,1};
        System.out.println(getMax(arr));
    }



    public  static int getMax(int[] arr){
        if(arr.length == 0){
            return  0;
        }
        int max = 0;
        int pre = 0;
        int cur = 0;

        for(int i : arr){
            max = Math.max(cur, pre+i);
            pre = cur;
            cur = max;
        }
        return max;

    }
}
